﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Xts
{
    namespace XInterBank
    {
        namespace TradingClient
        {
            public class XTradingQuery_QueryOrderInfo_Cookies
            {
                protected string x_orderId;
                public string OrderId { get { return x_orderId; } }

                protected string x_customOrderId;
                public string CustomOrderId { get { return x_customOrderId; } }

                protected DateTime x_oprtTime;
                public DateTime OprtTime { get { return x_oprtTime; } }

                public XTradingQuery_QueryOrderInfo_Cookies(string orderId, string customOrderId)
                {
                    x_orderId = orderId;
                    x_customOrderId = customOrderId;
                    x_oprtTime = DateTime.Now;
                }
            }
            public class XTradingQuery_BatchQueryOrderInfo_Cookies
            {
                protected string x_accountId;
                public string AccountId { get { return x_accountId; } }

                protected DateTime x_oprtTime;
                public DateTime OprtTime { get { return x_oprtTime; } }

                public XTradingQuery_BatchQueryOrderInfo_Cookies(string accountId)
                {
                    x_accountId = accountId;
                    x_oprtTime = DateTime.Now;
                }
            }

            public class XTradingQuery_QueryOrderFill_Cookies
            {
                protected string x_orderId;
                public string OrderId { get { return x_orderId; } }

                protected string x_customOrderId;
                public string CustomOrderId { get { return x_customOrderId; } }

                protected DateTime x_oprtTime;
                public DateTime OprtTime { get { return x_oprtTime; } }

                public XTradingQuery_QueryOrderFill_Cookies(string orderId, string customOrderId)
                {
                    x_orderId = orderId;
                    x_customOrderId = customOrderId;
                    x_oprtTime = DateTime.Now;
                }
            }

            public class XTradingQuery_BatchQueryOrderFill_Cookies
            {
                protected string x_accountId;
                public string AccountId { get { return x_accountId; } }

                protected DateTime x_oprtTime;
                public DateTime OprtTime { get { return x_oprtTime; } }

                public XTradingQuery_BatchQueryOrderFill_Cookies(string accountId)
                {
                    x_accountId = accountId;
                    x_oprtTime = DateTime.Now;
                }
            }

            public interface IXAmiTradingQueryCBHandler
            {
                void OnQueryOrderInfo(XBondOrderInfoQueryRsp rsp, XTradingQuery_QueryOrderInfo_Cookies cookies);
                void OnFailureQueryOrderInfo(XTradingQuery_QueryOrderInfo_Cookies cookies);
                void OnBatchQueryOrderInfo(XBondOrderInfoQueryRsp rsp, XTradingQuery_BatchQueryOrderInfo_Cookies cookies);
                void OnFailureBatchQueryOrderInfo(XTradingQuery_BatchQueryOrderInfo_Cookies cookies);
                void OnQueryOrderFill(XBondOrderFillQueryRsp rsp, XTradingQuery_QueryOrderFill_Cookies cookies);
                void OnFailureQueryOrderFill(XTradingQuery_QueryOrderFill_Cookies cookies);
                void OnBatchQueryOrderFill(XBondOrderFillQueryRsp rsp, XTradingQuery_BatchQueryOrderFill_Cookies cookies);
                void OnFailureBatchQueryOrderFill(XTradingQuery_BatchQueryOrderFill_Cookies cookies);
            }
            public class XAmiTradingQuery_QueryOrderInfoCallback
            {
                protected XTradingQuery_QueryOrderInfo_Cookies x_cookies;
                protected IXAmiTradingQueryCBHandler x_handler;
                protected Ice.Logger x_logger;

                public XAmiTradingQuery_QueryOrderInfoCallback(XTradingQuery_QueryOrderInfo_Cookies cookies,
                    ref IXAmiTradingQueryCBHandler handler, ref Ice.Logger logger)
                {
                    x_cookies = cookies;
                    x_handler = handler;
                    x_logger = logger;
                }

                public void QueryOrderInfoCB(XBondOrderInfoQueryRsp rsp)
                {
                    x_handler.OnQueryOrderInfo(rsp, x_cookies);
                }

                public void FailureQueryOrderInfoCB(Ice.Exception ex)
                {
                    x_logger.error(ex.Message);
                    x_handler.OnFailureQueryOrderInfo(x_cookies);
                }
            }
            public class XAmiTradingQuery_BatchQueryOrderInfoCallback
            {
                protected XTradingQuery_BatchQueryOrderInfo_Cookies x_cookies;
                protected IXAmiTradingQueryCBHandler x_handler;
                protected Ice.Logger x_logger;

                public XAmiTradingQuery_BatchQueryOrderInfoCallback(XTradingQuery_BatchQueryOrderInfo_Cookies cookies,
                    ref IXAmiTradingQueryCBHandler handler, ref Ice.Logger logger)
                {
                    x_cookies = cookies;
                    x_handler = handler;
                    x_logger = logger;
                }

                public void BatchQueryOrderInfoCB(XBondOrderInfoQueryRsp rsp)
                {
                    x_handler.OnBatchQueryOrderInfo(rsp, x_cookies);
                }

                public void FailureBatchQueryOrderInfoCB(Ice.Exception ex)
                {
                    x_logger.error(ex.Message);
                    x_handler.OnFailureBatchQueryOrderInfo(x_cookies);
                }
            }
            public class XAmiTradingQuery_QueryOrderFillCallback
            {
                protected XTradingQuery_QueryOrderFill_Cookies x_cookies;
                protected IXAmiTradingQueryCBHandler x_handler;
                protected Ice.Logger x_logger;

                public XAmiTradingQuery_QueryOrderFillCallback(XTradingQuery_QueryOrderFill_Cookies cookies,
                    ref IXAmiTradingQueryCBHandler handler, ref Ice.Logger logger)
                {
                    x_cookies = cookies;
                    x_handler = handler;
                    x_logger = logger;
                }

                public void QueryOrderFillCB(XBondOrderFillQueryRsp rsp)
                {
                    x_handler.OnQueryOrderFill(rsp, x_cookies);
                }

                public void FailureQueryOrderFillCB(Ice.Exception ex)
                {
                    x_logger.error(ex.Message);
                    x_handler.OnFailureQueryOrderFill(x_cookies);
                }
            }
            public class XAmiTradingQuery_BatchQueryOrderFillCallback
            {
                protected XTradingQuery_BatchQueryOrderFill_Cookies x_cookies;
                protected IXAmiTradingQueryCBHandler x_handler;
                protected Ice.Logger x_logger;

                public XAmiTradingQuery_BatchQueryOrderFillCallback(XTradingQuery_BatchQueryOrderFill_Cookies cookies,
                    ref IXAmiTradingQueryCBHandler handler, ref Ice.Logger logger)
                {
                    x_cookies = cookies;
                    x_handler = handler;
                    x_logger = logger;
                }

                public void BatchQueryOrderFillCB(XBondOrderFillQueryRsp rsp)
                {
                    x_handler.OnBatchQueryOrderFill(rsp, x_cookies);
                }

                public void FailureBatchQueryOrderFillCB(Ice.Exception ex)
                {
                    x_logger.error(ex.Message);
                    x_handler.OnFailureBatchQueryOrderFill(x_cookies);
                }
            }
        }
    }
}
